#coding:utf-8
import requests
from lxml import etree
import time
import json

url = "https://blog.csdn.net/"
headers = {
        "user-agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.124 Mobile Safari/537.36 Edg/102.0.1245.44"
}

res = requests.get(url,headers=headers)

print(res.status_code)
print(res.text)

tree = etree.HTML(res.text)
a_list = tree.xpath('/html/body/main/ul/li[1]/h2/a')


print( a_list )


'''

/html/body/div/ol/li[1]/div/div[2]/font/span[1]/a
/html/body/div
/html/body/div/ol/li[1]/div/div[2]/div/font/span
'''
# html = etree.HTML(res)
# divs = html.xpath("/html/body/div/ol/li")
# for div in divs:
#     title = div.xpath("./font/span[1]/a/text()")[0]
#     print(title)
#     time.sleep(1)
